
from package_allure.login import login
import pytest
import allure
from loguru import logger



@allure.epic("学生管理系统")
@allure.feature("登录")
@allure.link("http://localhost:81")
class TestLogin():

    # case1 : 输入正确的用户名和正确的密码进行登录
    @allure.title("输入正确的用户名和正确的密码进行登录")
    @allure.severity('critical')
    def test_login_success(self):
        print("1")
        logger.info("这是一条测试日志")
        expect_result = 1
        actual_result = login('admin','123456').get('code')
        with allure.step("登录结果:"):
            allure.attach.file(r'd:\a.jpg',name='登录',attachment_type=allure.attachment_type.JPG)
            allure.attach.file(r'E:\python_project\python_demo02\package_allure\zentao.log',name='登录',attachment_type=allure.attachment_type.TEXT)
        assert expect_result == actual_result

    # case2 : 输入正确的用户名和错误的密码进行登录
    @allure.title("输入正确的用户名和错误的密码进行登录")
    @allure.severity('normal')
    def test_password_is_wrong(self):
        print("2")
        expect_result = 3
        actual_result = login('admin', '1234567').get('code')
        assert expect_result == actual_result

    # case3 : 输入用户名和空的密码进行登录
    @allure.title("输入用户名和空的密码进行登录")
    @allure.severity('normal')
    def test_password_is_null(self):
        print("3")
        expect_result = 2
        actual_result = login('admin', '').get('code')
        assert expect_result == actual_result